<?php /* TIMECARD $Id: vw_reports.php,v 1.7 2005/06/27 21:17:54 hstanton Exp $ */
error_reporting( E_ALL );
global $m,$a,$tab,$TIMECARD_CONFIG;
global $dPconfig;

$report_type = dPgetParam( $_REQUEST, "report_type", '' );

// check permissions for this record
$canRead = !getDenyRead( $m );

if(!$TIMECARD_CONFIG['minimum_report_level']>=$AppUI->user_type){
	$AppUI->setMsg('Access denied', UI_MSG_ERROR);
	$AppUI->redirect();
}

$AppUI->savePlace();

// get the prefered date format
$df = $AppUI->getPref('SHDATEFORMAT');

?>
<table border="0" cellpadding="3" cellspacing="0" class="infopanel" width="100%">
<tr>
<td class="status">
<?
	if ($report_type) {
		showButton( 'reports index', "?m=timecard&tab=$tab" );
	}
	else {
		echo 'Select a report bellow';
	}
?>
</td>
</tr>
</table>
<?
if ($report_type) {
	$report_type = $AppUI->checkFileName( $report_type );
	$report_type = str_replace( ' ', '_', $report_type );
	require( $dPconfig['root_dir']."/modules/timecard/reports/$report_type.php" );
} else {
	$reports = $AppUI->readFiles( $dPconfig['root_dir']."/modules/timecard/reports", "\.php$" );
?>
<table id="idReportList" border="0" cellpadding="3" cellspacing="0" class="list" width="100%">
<tr><th>&nbsp;</th><th><?=$AppUI->_( 'Name' )?></th><th class="last"><?=$AppUI->_( 'Description' )?></th></tr>
<?
	$n = 1;
	foreach ($reports as $v) {
		$type = str_replace( ".php", "", $v );
		$desc_file = str_replace( ".php", ".$AppUI->user_locale.txt", $v );
		$desc = @file( $dPconfig['root_dir']."/modules/timecard/reports/$desc_file" );
?>
<tr class="second clickable" onclick="location.href='index.php?m=timecard&tab=<?=$tab?>&report_type=<?=$type?>'">
<td align="center"><?=$n++?></td>
<td><? echo @$desc[0] ? $desc[0] : $v; ?></td>
<td><? echo (@$desc[1] ? $desc[1] : ''); ?></td>
</tr>
<?	} ?>
</table>
<?
}
?>
<br><br><br>
<script>Table('idReportList').setNormalHover(1)</script>
